package com.hs.sfzy.controller;

import com.github.pagehelper.PageInfo;
import com.hs.sfzy.entity.PsyAss;
import com.hs.sfzy.entity.PsyTest;
import com.hs.sfzy.service.PsyAssService;
import com.hs.sfzy.until.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("psyAss")
public class PsyAssController {
    @Autowired
    PsyAssService psyService;

    @RequestMapping("page")
    public R selectAll(PsyAss psyAss
            ,@RequestParam(required = false, defaultValue = "1") int pageNum,
                                      @RequestParam(required = false, defaultValue = "4") int pageSize ) {
            return R.ok(psyService.selectAll(psyAss,pageNum, pageSize)) ;

    }
    @GetMapping("selectByName")
    public R selectByName(PsyAss psyAss,
                          @RequestParam(required = false,defaultValue = "1")int pageNum,
                          @RequestParam(required = false,defaultValue = "3")int pageSize){
        PageInfo<PsyAss> psyTestPageInfo = psyService.selectByName(psyAss, pageNum, pageSize);
        return R.ok(psyTestPageInfo);
    }

    @GetMapping("{id}")
    public R selectOne(@PathVariable("id") int id) {
        PsyAss psyAss = psyService.selectById(id);
        return R.ok(psyAss);
    }
}

